﻿using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using ihongma;
using System.Text;

namespace ihongma.Web.tools
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    //[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class channel : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            ihongma.BLL.category channel = new ihongma.BLL.category();
            DataTable dt=null;
            if(context.Request["id"]!=null)
            {
                dt=channel.GetList_meun(int.Parse(context.Request["id"].ToString()),9);
            }
            StringBuilder strTxt = new StringBuilder();
            strTxt.Append(" [");
            foreach (DataRow row in dt.Rows)
            {
                strTxt.Append("{");
                strTxt.Append(string.Format("\"code\":{0},\"name\":\"{1}\"", row[0], row[2]));
                strTxt.Append("},");
            }
            strTxt.Append("]");
            string str=strTxt.ToString();
            if (str.EndsWith(",]"))
            {
                str = str.Remove(str.Length - 2, 1);
            }
            

            context.Response.Write(str);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
